<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude, MagicHash, ScopedTypeVariables #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Module      :  Foreign.Marshal.Array</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Copyright   :  (c) The FFI task force 2001</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-9"></span><span class="hs-comment">--</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Maintainer  :  ffi@haskell.org</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Marshalling support: routines allocating, storing, and retrieving Haskell</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- lists that are represented as arrays in the foreign language</span><span>
</span><span id="line-16"></span><span class="hs-comment">--</span><span>
</span><span id="line-17"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Foreign.Marshal.Array</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-20"></span><span>  </span><span class="annot"><span class="hs-comment">-- * Marshalling arrays</span></span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Allocation</span></span><span>
</span><span id="line-23"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-24"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#mallocArray"><span class="hs-identifier">mallocArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#mallocArray0"><span class="hs-identifier">mallocArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier">allocaArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#allocaArray0"><span class="hs-identifier">allocaArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#reallocArray"><span class="hs-identifier">reallocArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#reallocArray0"><span class="hs-identifier">reallocArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#callocArray"><span class="hs-identifier">callocArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#callocArray0"><span class="hs-identifier">callocArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Marshalling</span></span><span>
</span><span id="line-37"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-38"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier">peekArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#peekArray0"><span class="hs-identifier">peekArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier">pokeArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#pokeArray0"><span class="hs-identifier">pokeArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Combined allocation and marshalling</span></span><span>
</span><span id="line-45"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-46"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#newArray"><span class="hs-identifier">newArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#newArray0"><span class="hs-identifier">newArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#withArray"><span class="hs-identifier">withArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-50"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#withArray0"><span class="hs-identifier">withArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#withArrayLen"><span class="hs-identifier">withArrayLen</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-53"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#withArrayLen0"><span class="hs-identifier">withArrayLen0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Copying</span></span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span>  </span><span class="annot"><span class="hs-comment">-- | (argument order: destination, source)</span></span><span>
</span><span id="line-58"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#copyArray"><span class="hs-identifier">copyArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-59"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#moveArray"><span class="hs-identifier">moveArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Finding the length</span></span><span>
</span><span id="line-62"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-63"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#lengthArray0"><span class="hs-identifier">lengthArray0</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Indexing</span></span><span>
</span><span id="line-66"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-67"></span><span>  </span><span class="annot"><a href="Foreign.Marshal.Array.html#advancePtr"><span class="hs-identifier">advancePtr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-68"></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Ptr.html"><span class="hs-identifier">Foreign.Ptr</span></a></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#plusPtr"><span class="hs-identifier">plusPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Storable.html"><span class="hs-identifier">Foreign.Storable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier">Storable</span></a></span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Storable.html#alignment"><span class="hs-identifier">alignment</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier">sizeOf</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Foreign.Storable.html#peekElemOff"><span class="hs-identifier">peekElemOff</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Foreign.Storable.html#pokeElemOff"><span class="hs-identifier">pokeElemOff</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Marshal.Alloc.html"><span class="hs-identifier">Foreign.Marshal.Alloc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Marshal.Alloc.html#mallocBytes"><span class="hs-identifier">mallocBytes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.Marshal.Alloc.html#callocBytes"><span class="hs-identifier">callocBytes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.Marshal.Alloc.html#allocaBytesAligned"><span class="hs-identifier">allocaBytesAligned</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.Marshal.Alloc.html#reallocBytes"><span class="hs-identifier">reallocBytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Marshal.Utils.html"><span class="hs-identifier">Foreign.Marshal.Utils</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Marshal.Utils.html#copyBytes"><span class="hs-identifier">copyBytes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.Marshal.Utils.html#moveBytes"><span class="hs-identifier">moveBytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.List.html"><span class="hs-identifier">GHC.List</span></a></span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-comment">-- allocation</span><span>
</span><span id="line-80"></span><span class="hs-comment">-- ----------</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-comment">-- |Allocate storage for the given number of elements of a storable type</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- (like 'Foreign.Marshal.Alloc.malloc', but for multiple elements).</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="annot"><a href="Foreign.Marshal.Array.html#mallocArray"><span class="hs-identifier hs-type">mallocArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679538696"><span class="annot"><a href="#local-6989586621679538696"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538696"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538696"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span id="mallocArray"><span class="annot"><span class="annottext">mallocArray :: forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#mallocArray"><span class="hs-identifier hs-var hs-var">mallocArray</span></a></span></span><span>  </span><span id="local-6989586621679538581"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538581"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (Ptr a)
forall a. Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Alloc.html#mallocBytes"><span class="hs-identifier hs-var">mallocBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538581"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538696"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-comment">-- |Like 'mallocArray', but add an extra position to hold a special</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- termination element.</span><span>
</span><span id="line-90"></span><span class="hs-comment">--</span><span>
</span><span id="line-91"></span><span id="local-6989586621679538578"><span class="annot"><a href="Foreign.Marshal.Array.html#mallocArray0"><span class="hs-identifier hs-type">mallocArray0</span></a></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538578"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538578"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-92"></span><span id="mallocArray0"><span class="annot"><span class="annottext">mallocArray0 :: forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#mallocArray0"><span class="hs-identifier hs-var hs-var">mallocArray0</span></a></span></span><span> </span><span id="local-6989586621679538573"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538573"><span class="hs-identifier hs-var">size</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (Ptr a)
forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#mallocArray"><span class="hs-identifier hs-var">mallocArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538573"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-comment">-- |Like 'mallocArray', but allocated memory is filled with bytes of value zero.</span><span>
</span><span id="line-95"></span><span class="hs-comment">--</span><span>
</span><span id="line-96"></span><span class="annot"><a href="Foreign.Marshal.Array.html#callocArray"><span class="hs-identifier hs-type">callocArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679538571"><span class="annot"><a href="#local-6989586621679538571"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538571"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538571"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-97"></span><span id="callocArray"><span class="annot"><span class="annottext">callocArray :: forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#callocArray"><span class="hs-identifier hs-var hs-var">callocArray</span></a></span></span><span> </span><span id="local-6989586621679538565"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538565"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (Ptr a)
forall a. Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Alloc.html#callocBytes"><span class="hs-identifier hs-var">callocBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538565"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538571"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-comment">-- |Like 'callocArray0', but allocated memory is filled with bytes of value</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- zero.</span><span>
</span><span id="line-101"></span><span class="hs-comment">--</span><span>
</span><span id="line-102"></span><span id="local-6989586621679538564"><span class="annot"><a href="Foreign.Marshal.Array.html#callocArray0"><span class="hs-identifier hs-type">callocArray0</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538564"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538564"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-103"></span><span id="callocArray0"><span class="annot"><span class="annottext">callocArray0 :: forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#callocArray0"><span class="hs-identifier hs-var hs-var">callocArray0</span></a></span></span><span> </span><span id="local-6989586621679538559"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538559"><span class="hs-identifier hs-var">size</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (Ptr a)
forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#callocArray"><span class="hs-identifier hs-var">callocArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538559"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-comment">-- |Temporarily allocate space for the given number of elements</span><span>
</span><span id="line-106"></span><span class="hs-comment">-- (like 'Foreign.Marshal.Alloc.alloca', but for multiple elements).</span><span>
</span><span id="line-107"></span><span class="hs-comment">--</span><span>
</span><span id="line-108"></span><span class="annot"><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-type">allocaArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679538684"><span class="annot"><a href="#local-6989586621679538684"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span id="local-6989586621679538683"><span class="annot"><a href="#local-6989586621679538683"><span class="hs-identifier hs-type">b</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538684"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538684"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538683"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538683"><span class="hs-identifier hs-type">b</span></a></span><span>
</span><span id="line-109"></span><span id="allocaArray"><span class="annot"><span class="annottext">allocaArray :: forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var hs-var">allocaArray</span></a></span></span><span> </span><span id="local-6989586621679538550"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538550"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. Int -&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Alloc.html#allocaBytesAligned"><span class="hs-identifier hs-var">allocaBytesAligned</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538550"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538684"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span>                                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#alignment"><span class="hs-identifier hs-var">alignment</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538684"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- |Like 'allocaArray', but add an extra position to hold a special</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- termination element.</span><span>
</span><span id="line-114"></span><span class="hs-comment">--</span><span>
</span><span id="line-115"></span><span id="local-6989586621679538548"><span id="local-6989586621679538549"><span class="annot"><a href="Foreign.Marshal.Array.html#allocaArray0"><span class="hs-identifier hs-type">allocaArray0</span></a></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538549"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538549"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538548"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538548"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-116"></span><span id="allocaArray0"><span class="annot"><span class="annottext">allocaArray0 :: forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray0"><span class="hs-identifier hs-var hs-var">allocaArray0</span></a></span></span><span> </span><span id="local-6989586621679538543"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538543"><span class="hs-identifier hs-var">size</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var">allocaArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538543"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-117"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Foreign.Marshal.Array.html#allocaArray0"><span class="hs-pragma hs-type">allocaArray0</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-118"></span><span>  </span><span class="hs-comment">-- needed to get allocaArray to inline into withCString, for unknown</span><span>
</span><span id="line-119"></span><span>  </span><span class="hs-comment">-- reasons --SDM 23/4/2010, see #4004 for benchmark</span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span class="hs-comment">-- |Adjust the size of an array</span><span>
</span><span id="line-122"></span><span class="hs-comment">--</span><span>
</span><span id="line-123"></span><span class="annot"><a href="Foreign.Marshal.Array.html#reallocArray"><span class="hs-identifier hs-type">reallocArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679538676"><span class="annot"><a href="#local-6989586621679538676"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538676"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538676"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538676"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-124"></span><span id="reallocArray"><span class="annot"><span class="annottext">reallocArray :: forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#reallocArray"><span class="hs-identifier hs-var hs-var">reallocArray</span></a></span></span><span> </span><span id="local-6989586621679538537"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538537"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679538536"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538536"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO (Ptr a)
forall a. Ptr a -&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Alloc.html#reallocBytes"><span class="hs-identifier hs-var">reallocBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538537"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538536"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538676"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="hs-comment">-- |Adjust the size of an array including an extra position for the end marker.</span><span>
</span><span id="line-127"></span><span class="hs-comment">--</span><span>
</span><span id="line-128"></span><span id="local-6989586621679538535"><span class="annot"><a href="Foreign.Marshal.Array.html#reallocArray0"><span class="hs-identifier hs-type">reallocArray0</span></a></span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538535"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538535"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538535"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-129"></span><span id="reallocArray0"><span class="annot"><span class="annottext">reallocArray0 :: forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#reallocArray0"><span class="hs-identifier hs-var hs-var">reallocArray0</span></a></span></span><span> </span><span id="local-6989586621679538530"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538530"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679538529"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538529"><span class="hs-identifier hs-var">size</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO (Ptr a)
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#reallocArray"><span class="hs-identifier hs-var">reallocArray</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538530"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538529"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-comment">-- marshalling</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- -----------</span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span class="hs-comment">-- |Convert an array of given length into a Haskell list.  The implementation</span><span>
</span><span id="line-136"></span><span class="hs-comment">-- is tail-recursive and so uses constant stack space.</span><span>
</span><span id="line-137"></span><span class="hs-comment">--</span><span>
</span><span id="line-138"></span><span id="local-6989586621679538672"><span class="annot"><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier hs-type">peekArray</span></a></span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538672"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538672"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538672"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-139"></span><span id="peekArray"><span class="annot"><span class="annottext">peekArray :: forall a. Storable a =&gt; Int -&gt; Ptr a -&gt; IO [a]
</span><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier hs-var hs-var">peekArray</span></a></span></span><span> </span><span id="local-6989586621679538520"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538520"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span id="local-6989586621679538519"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538519"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538520"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; IO [a]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-140"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [a] -&gt; IO [a]
</span><a href="#local-6989586621679538517"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538520"><span class="hs-identifier hs-var">size</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-141"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-142"></span><span>    </span><span id="local-6989586621679538517"><span class="annot"><span class="annottext">f :: Int -&gt; [a] -&gt; IO [a]
</span><a href="#local-6989586621679538517"><span class="hs-identifier hs-var hs-var">f</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621679538506"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538506"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679538505"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538505"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO a
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; IO a
</span><a href="Foreign.Storable.html#peekElemOff"><span class="hs-identifier hs-var">peekElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538519"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; IO [a]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538505"><span class="hs-identifier hs-var">e</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538506"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-143"></span><span>    </span><span class="annot"><a href="#local-6989586621679538517"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span id="local-6989586621679538504"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538504"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679538503"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538503"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679538502"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538502"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO a
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; IO a
</span><a href="Foreign.Storable.html#peekElemOff"><span class="hs-identifier hs-var">peekElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538519"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538504"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [a] -&gt; IO [a]
</span><a href="#local-6989586621679538517"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538504"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538502"><span class="hs-identifier hs-var">e</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538503"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span class="hs-comment">-- |Convert an array terminated by the given end marker into a Haskell list</span><span>
</span><span id="line-146"></span><span class="hs-comment">--</span><span>
</span><span id="line-147"></span><span id="local-6989586621679538666"><span class="annot"><a href="Foreign.Marshal.Array.html#peekArray0"><span class="hs-identifier hs-type">peekArray0</span></a></span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538666"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-type">Eq</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538666"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538666"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538666"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538666"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-148"></span><span id="peekArray0"><span class="annot"><span class="annottext">peekArray0 :: forall a. (Storable a, Eq a) =&gt; a -&gt; Ptr a -&gt; IO [a]
</span><a href="Foreign.Marshal.Array.html#peekArray0"><span class="hs-identifier hs-var hs-var">peekArray0</span></a></span></span><span> </span><span id="local-6989586621679538495"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538495"><span class="hs-identifier hs-var">marker</span></a></span></span><span> </span><span id="local-6989586621679538494"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538494"><span class="hs-identifier hs-var">ptr</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-149"></span><span>  </span><span id="local-6989586621679538493"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538493"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; Ptr a -&gt; IO Int
forall a. (Storable a, Eq a) =&gt; a -&gt; Ptr a -&gt; IO Int
</span><a href="Foreign.Marshal.Array.html#lengthArray0"><span class="hs-identifier hs-var">lengthArray0</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538495"><span class="hs-identifier hs-var">marker</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538494"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-150"></span><span>  </span><span class="annot"><span class="annottext">Int -&gt; Ptr a -&gt; IO [a]
forall a. Storable a =&gt; Int -&gt; Ptr a -&gt; IO [a]
</span><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier hs-var">peekArray</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538493"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538494"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span class="hs-comment">-- |Write the list elements consecutive into memory</span><span>
</span><span id="line-153"></span><span class="hs-comment">--</span><span>
</span><span id="line-154"></span><span id="local-6989586621679538663"><span class="annot"><a href="Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier hs-type">pokeArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538663"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538663"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538663"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-155"></span><span id="pokeArray"><span class="annot"><span class="annottext">pokeArray :: forall a. Storable a =&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier hs-var hs-var">pokeArray</span></a></span></span><span> </span><span id="local-6989586621679538491"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538491"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679538490"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538490"><span class="hs-identifier hs-var">vals0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Int# -&gt; IO ()
</span><a href="#local-6989586621679538489"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538490"><span class="hs-identifier hs-var">vals0</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span>
</span><span id="line-156"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679538489"><span class="annot"><span class="annottext">go :: [a] -&gt; Int# -&gt; IO ()
</span><a href="#local-6989586621679538489"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-157"></span><span>        </span><span class="annot"><a href="#local-6989586621679538489"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538485"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538485"><span class="hs-identifier hs-var">val</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679538484"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538484"><span class="hs-identifier hs-var">vals</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679538483"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538483"><span class="hs-identifier hs-var">n#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; a -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="Foreign.Storable.html#pokeElemOff"><span class="hs-identifier hs-var">pokeElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538491"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Int
</span><a href="../../ghc-prim/src/GHC.Types.html#I%23"><span class="hs-identifier hs-var">I#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538483"><span class="hs-identifier hs-var">n#</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538485"><span class="hs-identifier hs-var">val</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Int# -&gt; IO ()
</span><a href="#local-6989586621679538489"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538484"><span class="hs-identifier hs-var">vals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538483"><span class="hs-identifier hs-var">n#</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%2B%23"><span class="hs-operator hs-var">+#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">1#</span></span><span class="hs-special">)</span><span>
</span><span id="line-158"></span><span>
</span><span id="line-159"></span><span class="hs-comment">-- |Write the list elements consecutive into memory and terminate them with the</span><span>
</span><span id="line-160"></span><span class="hs-comment">-- given marker element</span><span>
</span><span id="line-161"></span><span class="hs-comment">--</span><span>
</span><span id="line-162"></span><span id="local-6989586621679538661"><span class="annot"><a href="Foreign.Marshal.Array.html#pokeArray0"><span class="hs-identifier hs-type">pokeArray0</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538661"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538661"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538661"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538661"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-163"></span><span id="pokeArray0"><span class="annot"><span class="annottext">pokeArray0 :: forall a. Storable a =&gt; a -&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#pokeArray0"><span class="hs-identifier hs-var hs-var">pokeArray0</span></a></span></span><span> </span><span id="local-6989586621679538481"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538481"><span class="hs-identifier hs-var">marker</span></a></span></span><span> </span><span id="local-6989586621679538480"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538480"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679538479"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538479"><span class="hs-identifier hs-var">vals0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Int# -&gt; IO ()
</span><a href="#local-6989586621679538478"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538479"><span class="hs-identifier hs-var">vals0</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679538478"><span class="annot"><span class="annottext">go :: [a] -&gt; Int# -&gt; IO ()
</span><a href="#local-6989586621679538478"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621679538474"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538474"><span class="hs-identifier hs-var">n#</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; a -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="Foreign.Storable.html#pokeElemOff"><span class="hs-identifier hs-var">pokeElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538480"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Int
</span><a href="../../ghc-prim/src/GHC.Types.html#I%23"><span class="hs-identifier hs-var">I#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538474"><span class="hs-identifier hs-var">n#</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538481"><span class="hs-identifier hs-var">marker</span></a></span><span>
</span><span id="line-165"></span><span>        </span><span class="annot"><a href="#local-6989586621679538478"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538473"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538473"><span class="hs-identifier hs-var">val</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679538472"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538472"><span class="hs-identifier hs-var">vals</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679538471"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538471"><span class="hs-identifier hs-var">n#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; a -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="Foreign.Storable.html#pokeElemOff"><span class="hs-identifier hs-var">pokeElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538480"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Int
</span><a href="../../ghc-prim/src/GHC.Types.html#I%23"><span class="hs-identifier hs-var">I#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538471"><span class="hs-identifier hs-var">n#</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538473"><span class="hs-identifier hs-var">val</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Int# -&gt; IO ()
</span><a href="#local-6989586621679538478"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538472"><span class="hs-identifier hs-var">vals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679538471"><span class="hs-identifier hs-var">n#</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%2B%23"><span class="hs-operator hs-var">+#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">1#</span></span><span class="hs-special">)</span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span class="hs-comment">-- combined allocation and marshalling</span><span>
</span><span id="line-168"></span><span class="hs-comment">-- -----------------------------------</span><span>
</span><span id="line-169"></span><span>
</span><span id="line-170"></span><span class="hs-comment">-- |Write a list of storable elements into a newly allocated, consecutive</span><span>
</span><span id="line-171"></span><span class="hs-comment">-- sequence of storable values</span><span>
</span><span id="line-172"></span><span class="hs-comment">-- (like 'Foreign.Marshal.Utils.new', but for multiple elements).</span><span>
</span><span id="line-173"></span><span class="hs-comment">--</span><span>
</span><span id="line-174"></span><span id="local-6989586621679538659"><span class="annot"><a href="Foreign.Marshal.Array.html#newArray"><span class="hs-identifier hs-type">newArray</span></a></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538659"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538659"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538659"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-175"></span><span id="newArray"><span class="annot"><span class="annottext">newArray :: forall a. Storable a =&gt; [a] -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#newArray"><span class="hs-identifier hs-var hs-var">newArray</span></a></span></span><span> </span><span id="local-6989586621679538464"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538464"><span class="hs-identifier hs-var">vals</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-176"></span><span>  </span><span id="local-6989586621679538463"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538463"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (Ptr a)
forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#mallocArray"><span class="hs-identifier hs-var">mallocArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a] -&gt; Int
forall a. [a] -&gt; Int
</span><a href="GHC.List.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538464"><span class="hs-identifier hs-var">vals</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>  </span><span class="annot"><span class="annottext">Ptr a -&gt; [a] -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier hs-var">pokeArray</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538463"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538464"><span class="hs-identifier hs-var">vals</span></a></span><span>
</span><span id="line-178"></span><span>  </span><span class="annot"><span class="annottext">Ptr a -&gt; IO (Ptr a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538463"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-comment">-- |Write a list of storable elements into a newly allocated, consecutive</span><span>
</span><span id="line-181"></span><span class="hs-comment">-- sequence of storable values, where the end is fixed by the given end marker</span><span>
</span><span id="line-182"></span><span class="hs-comment">--</span><span>
</span><span id="line-183"></span><span id="local-6989586621679538656"><span class="annot"><a href="Foreign.Marshal.Array.html#newArray0"><span class="hs-identifier hs-type">newArray0</span></a></span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538656"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538656"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538656"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538656"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-184"></span><span id="newArray0"><span class="annot"><span class="annottext">newArray0 :: forall a. Storable a =&gt; a -&gt; [a] -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#newArray0"><span class="hs-identifier hs-var hs-var">newArray0</span></a></span></span><span> </span><span id="local-6989586621679538455"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538455"><span class="hs-identifier hs-var">marker</span></a></span></span><span> </span><span id="local-6989586621679538454"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538454"><span class="hs-identifier hs-var">vals</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-185"></span><span>  </span><span id="local-6989586621679538453"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538453"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (Ptr a)
forall a. Storable a =&gt; Int -&gt; IO (Ptr a)
</span><a href="Foreign.Marshal.Array.html#mallocArray0"><span class="hs-identifier hs-var">mallocArray0</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a] -&gt; Int
forall a. [a] -&gt; Int
</span><a href="GHC.List.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538454"><span class="hs-identifier hs-var">vals</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span>  </span><span class="annot"><span class="annottext">a -&gt; Ptr a -&gt; [a] -&gt; IO ()
forall a. Storable a =&gt; a -&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#pokeArray0"><span class="hs-identifier hs-var">pokeArray0</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538455"><span class="hs-identifier hs-var">marker</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538453"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538454"><span class="hs-identifier hs-var">vals</span></a></span><span>
</span><span id="line-187"></span><span>  </span><span class="annot"><span class="annottext">Ptr a -&gt; IO (Ptr a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538453"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span class="hs-comment">-- |Temporarily store a list of storable values in memory</span><span>
</span><span id="line-190"></span><span class="hs-comment">-- (like 'Foreign.Marshal.Utils.with', but for multiple elements).</span><span>
</span><span id="line-191"></span><span class="hs-comment">--</span><span>
</span><span id="line-192"></span><span id="local-6989586621679538653"><span id="local-6989586621679538654"><span class="annot"><a href="Foreign.Marshal.Array.html#withArray"><span class="hs-identifier hs-type">withArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538654"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538654"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538654"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538653"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538653"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-193"></span><span id="withArray"><span class="annot"><span class="annottext">withArray :: forall a b. Storable a =&gt; [a] -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#withArray"><span class="hs-identifier hs-var hs-var">withArray</span></a></span></span><span> </span><span id="local-6989586621679538450"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538450"><span class="hs-identifier hs-var">vals</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; (Int -&gt; Ptr a -&gt; IO b) -&gt; IO b
forall a b. Storable a =&gt; [a] -&gt; (Int -&gt; Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#withArrayLen"><span class="hs-identifier hs-var">withArrayLen</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538450"><span class="hs-identifier hs-var">vals</span></a></span><span> </span><span class="annot"><span class="annottext">((Int -&gt; Ptr a -&gt; IO b) -&gt; IO b)
-&gt; ((Ptr a -&gt; IO b) -&gt; Int -&gt; Ptr a -&gt; IO b)
-&gt; (Ptr a -&gt; IO b)
-&gt; IO b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Ptr a -&gt; IO b) -&gt; Int -&gt; Ptr a -&gt; IO b
forall a b. a -&gt; b -&gt; a
</span><a href="GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="hs-comment">-- |Like 'withArray', but the action gets the number of values</span><span>
</span><span id="line-196"></span><span class="hs-comment">-- as an additional parameter</span><span>
</span><span id="line-197"></span><span class="hs-comment">--</span><span>
</span><span id="line-198"></span><span id="local-6989586621679538649"><span id="local-6989586621679538650"><span class="annot"><a href="Foreign.Marshal.Array.html#withArrayLen"><span class="hs-identifier hs-type">withArrayLen</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538650"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538650"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538650"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538649"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538649"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-199"></span><span id="withArrayLen"><span class="annot"><span class="annottext">withArrayLen :: forall a b. Storable a =&gt; [a] -&gt; (Int -&gt; Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#withArrayLen"><span class="hs-identifier hs-var hs-var">withArrayLen</span></a></span></span><span> </span><span id="local-6989586621679538443"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538443"><span class="hs-identifier hs-var">vals</span></a></span></span><span> </span><span id="local-6989586621679538442"><span class="annot"><span class="annottext">Int -&gt; Ptr a -&gt; IO b
</span><a href="#local-6989586621679538442"><span class="hs-identifier hs-var">f</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span>
</span><span id="line-200"></span><span>  </span><span class="annot"><span class="annottext">Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var">allocaArray</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538441"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO b) -&gt; IO b) -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679538440"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538440"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-201"></span><span>      </span><span class="annot"><span class="annottext">Ptr a -&gt; [a] -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier hs-var">pokeArray</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538440"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538443"><span class="hs-identifier hs-var">vals</span></a></span><span>
</span><span id="line-202"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; Ptr a -&gt; IO b
</span><a href="#local-6989586621679538442"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538441"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538440"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-203"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-204"></span><span>    </span><span id="local-6989586621679538441"><span class="annot"><span class="annottext">len :: Int
</span><a href="#local-6989586621679538441"><span class="hs-identifier hs-var hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Int
forall a. [a] -&gt; Int
</span><a href="GHC.List.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538443"><span class="hs-identifier hs-var">vals</span></a></span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span class="hs-comment">-- |Like 'withArray', but a terminator indicates where the array ends</span><span>
</span><span id="line-207"></span><span class="hs-comment">--</span><span>
</span><span id="line-208"></span><span id="local-6989586621679538637"><span id="local-6989586621679538638"><span class="annot"><a href="Foreign.Marshal.Array.html#withArray0"><span class="hs-identifier hs-type">withArray0</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538638"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538638"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538638"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538638"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538637"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538637"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-209"></span><span id="withArray0"><span class="annot"><span class="annottext">withArray0 :: forall a b. Storable a =&gt; a -&gt; [a] -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#withArray0"><span class="hs-identifier hs-var hs-var">withArray0</span></a></span></span><span> </span><span id="local-6989586621679538437"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538437"><span class="hs-identifier hs-var">marker</span></a></span></span><span> </span><span id="local-6989586621679538436"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538436"><span class="hs-identifier hs-var">vals</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; (Int -&gt; Ptr a -&gt; IO b) -&gt; IO b
forall a b.
Storable a =&gt;
a -&gt; [a] -&gt; (Int -&gt; Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#withArrayLen0"><span class="hs-identifier hs-var">withArrayLen0</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538437"><span class="hs-identifier hs-var">marker</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538436"><span class="hs-identifier hs-var">vals</span></a></span><span> </span><span class="annot"><span class="annottext">((Int -&gt; Ptr a -&gt; IO b) -&gt; IO b)
-&gt; ((Ptr a -&gt; IO b) -&gt; Int -&gt; Ptr a -&gt; IO b)
-&gt; (Ptr a -&gt; IO b)
-&gt; IO b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Ptr a -&gt; IO b) -&gt; Int -&gt; Ptr a -&gt; IO b
forall a b. a -&gt; b -&gt; a
</span><a href="GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span>
</span><span id="line-210"></span><span>
</span><span id="line-211"></span><span class="hs-comment">-- |Like 'withArrayLen', but a terminator indicates where the array ends</span><span>
</span><span id="line-212"></span><span class="hs-comment">--</span><span>
</span><span id="line-213"></span><span id="local-6989586621679538633"><span id="local-6989586621679538634"><span class="annot"><a href="Foreign.Marshal.Array.html#withArrayLen0"><span class="hs-identifier hs-type">withArrayLen0</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538634"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538634"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679538634"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538634"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538633"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538633"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-214"></span><span id="withArrayLen0"><span class="annot"><span class="annottext">withArrayLen0 :: forall a b.
Storable a =&gt;
a -&gt; [a] -&gt; (Int -&gt; Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#withArrayLen0"><span class="hs-identifier hs-var hs-var">withArrayLen0</span></a></span></span><span> </span><span id="local-6989586621679538429"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538429"><span class="hs-identifier hs-var">marker</span></a></span></span><span> </span><span id="local-6989586621679538428"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538428"><span class="hs-identifier hs-var">vals</span></a></span></span><span> </span><span id="local-6989586621679538427"><span class="annot"><span class="annottext">Int -&gt; Ptr a -&gt; IO b
</span><a href="#local-6989586621679538427"><span class="hs-identifier hs-var">f</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span>
</span><span id="line-215"></span><span>  </span><span class="annot"><span class="annottext">Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray0"><span class="hs-identifier hs-var">allocaArray0</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538426"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO b) -&gt; IO b) -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679538425"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538425"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-216"></span><span>      </span><span class="annot"><span class="annottext">a -&gt; Ptr a -&gt; [a] -&gt; IO ()
forall a. Storable a =&gt; a -&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#pokeArray0"><span class="hs-identifier hs-var">pokeArray0</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538429"><span class="hs-identifier hs-var">marker</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538425"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538428"><span class="hs-identifier hs-var">vals</span></a></span><span>
</span><span id="line-217"></span><span>      </span><span id="local-6989586621679538424"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679538424"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr a -&gt; IO b
</span><a href="#local-6989586621679538427"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538426"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538425"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-218"></span><span>      </span><span class="annot"><span class="annottext">b -&gt; IO b
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679538424"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-219"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-220"></span><span>    </span><span id="local-6989586621679538426"><span class="annot"><span class="annottext">len :: Int
</span><a href="#local-6989586621679538426"><span class="hs-identifier hs-var hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Int
forall a. [a] -&gt; Int
</span><a href="GHC.List.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679538428"><span class="hs-identifier hs-var">vals</span></a></span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span class="hs-comment">-- copying (argument order: destination, source)</span><span>
</span><span id="line-224"></span><span class="hs-comment">-- -------</span><span>
</span><span id="line-225"></span><span>
</span><span id="line-226"></span><span class="hs-comment">-- |Copy the given number of elements from the second array (source) into the</span><span>
</span><span id="line-227"></span><span class="hs-comment">-- first array (destination); the copied areas may /not/ overlap</span><span>
</span><span id="line-228"></span><span class="hs-comment">--</span><span>
</span><span id="line-229"></span><span class="annot"><a href="Foreign.Marshal.Array.html#copyArray"><span class="hs-identifier hs-type">copyArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679538630"><span class="annot"><a href="#local-6989586621679538630"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538630"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538630"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538630"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-230"></span><span id="copyArray"><span class="annot"><span class="annottext">copyArray :: forall a. Storable a =&gt; Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#copyArray"><span class="hs-identifier hs-var hs-var">copyArray</span></a></span></span><span> </span><span id="local-6989586621679538418"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538418"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span id="local-6989586621679538417"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538417"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span id="local-6989586621679538416"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538416"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
forall a. Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="Foreign.Marshal.Utils.html#copyBytes"><span class="hs-identifier hs-var">copyBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538418"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538417"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538416"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538630"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-231"></span><span>
</span><span id="line-232"></span><span class="hs-comment">-- |Copy the given number of elements from the second array (source) into the</span><span>
</span><span id="line-233"></span><span class="hs-comment">-- first array (destination); the copied areas /may/ overlap</span><span>
</span><span id="line-234"></span><span class="hs-comment">--</span><span>
</span><span id="line-235"></span><span class="annot"><a href="Foreign.Marshal.Array.html#moveArray"><span class="hs-identifier hs-type">moveArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679538415"><span class="annot"><a href="#local-6989586621679538415"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538415"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538415"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538415"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-236"></span><span id="moveArray"><span class="annot"><span class="annottext">moveArray :: forall a. Storable a =&gt; Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="Foreign.Marshal.Array.html#moveArray"><span class="hs-identifier hs-var hs-var">moveArray</span></a></span></span><span>  </span><span id="local-6989586621679538409"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538409"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span id="local-6989586621679538408"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538408"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span id="local-6989586621679538407"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538407"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
forall a. Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="Foreign.Marshal.Utils.html#moveBytes"><span class="hs-identifier hs-var">moveBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538409"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538408"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538407"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538415"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-237"></span><span>
</span><span id="line-238"></span><span>
</span><span id="line-239"></span><span class="hs-comment">-- finding the length</span><span>
</span><span id="line-240"></span><span class="hs-comment">-- ------------------</span><span>
</span><span id="line-241"></span><span>
</span><span id="line-242"></span><span class="hs-comment">-- |Return the number of elements in an array, excluding the terminator</span><span>
</span><span id="line-243"></span><span class="hs-comment">--</span><span>
</span><span id="line-244"></span><span id="local-6989586621679538664"><span class="annot"><a href="Foreign.Marshal.Array.html#lengthArray0"><span class="hs-identifier hs-type">lengthArray0</span></a></span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538664"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-type">Eq</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538664"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538664"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538664"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span></span><span>
</span><span id="line-245"></span><span id="lengthArray0"><span class="annot"><span class="annottext">lengthArray0 :: forall a. (Storable a, Eq a) =&gt; a -&gt; Ptr a -&gt; IO Int
</span><a href="Foreign.Marshal.Array.html#lengthArray0"><span class="hs-identifier hs-var hs-var">lengthArray0</span></a></span></span><span> </span><span id="local-6989586621679538404"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538404"><span class="hs-identifier hs-var">marker</span></a></span></span><span> </span><span id="local-6989586621679538403"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538403"><span class="hs-identifier hs-var">ptr</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
</span><a href="#local-6989586621679538402"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-246"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-247"></span><span>    </span><span id="local-6989586621679538402"><span class="annot"><span class="annottext">loop :: Int -&gt; IO Int
</span><a href="#local-6989586621679538402"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span id="local-6989586621679538395"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538395"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-248"></span><span>        </span><span id="local-6989586621679538394"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538394"><span class="hs-identifier hs-var">val</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO a
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; IO a
</span><a href="Foreign.Storable.html#peekElemOff"><span class="hs-identifier hs-var">peekElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538403"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538395"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-249"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538394"><span class="hs-identifier hs-var">val</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679538404"><span class="hs-identifier hs-var">marker</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538395"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
</span><a href="#local-6989586621679538402"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538395"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span class="hs-comment">-- indexing</span><span>
</span><span id="line-253"></span><span class="hs-comment">-- --------</span><span>
</span><span id="line-254"></span><span>
</span><span id="line-255"></span><span class="hs-comment">-- |Advance a pointer into an array by the given number of elements</span><span>
</span><span id="line-256"></span><span class="hs-comment">--</span><span>
</span><span id="line-257"></span><span class="annot"><a href="Foreign.Marshal.Array.html#advancePtr"><span class="hs-identifier hs-type">advancePtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679538624"><span class="annot"><a href="#local-6989586621679538624"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538624"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538624"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538624"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-258"></span><span id="advancePtr"><span class="annot"><span class="annottext">advancePtr :: forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; Ptr a
</span><a href="Foreign.Marshal.Array.html#advancePtr"><span class="hs-identifier hs-var hs-var">advancePtr</span></a></span></span><span> </span><span id="local-6989586621679538388"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538388"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621679538387"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538387"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679538388"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; Ptr a
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679538387"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538624"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-259"></span></pre></body></html>